/*
 * @Description: app module
 * @Author: chenju
 * @Date: 2021-06-01 11:25:46
 * @LastEditors: chenju
 * @LastEditTime: 2021-07-13 16:07:41
 */
import type { Store as VuexStore, CommitOptions, Module } from 'vuex';

import type { RootState } from '@/store';
import { state } from './state';
import { mutations } from './mutations';
import  type {  Mutations } from './mutations';
import { actions } from './actions';
import type { AppState } from './state';

export { AppState };

export type AppStore<S = AppState> = Omit<VuexStore<S>, 'getters' | 'commit' | 'dispatch'> & {
  commit<K extends keyof Mutations, P extends Parameters<Mutations[K]>[1]>(
    key: K,
    payload: P,
    options?: CommitOptions
  ): ReturnType<Mutations[K]>;
};

export const store: Module<AppState, RootState> = {
  state,
  mutations,
  actions
};
